#include <REGX52.H>
#include <INTRINS.H>
#include "time0.h"
#include "Nixie.h"
#include "key.h"
#include "delay.h"

sbit PWM_DA=P2^1;

unsigned char Compare = 0;
unsigned char KeyNum;

void main()
{
	unsigned int i = 0;
	
	Timer0_Init();		//定时器初始化
	P2 = 0xFF;
	
	for(i=0; i<100; i++)
	{
		Compare = i;
		Delay(10);		//每个亮度延时10ms，不要太快
	}
	for(i=100; i>0; i--)
	{
		Compare = i;
		Delay(10);		//每个亮度延时10ms，不要太快
	}

}

/**
  * @brief  定时器0中断处理函数模版
  * @param  无
  * @retval 无
  */
void Timer0_Routine(void) interrupt 1
{
	static unsigned int count = 0;
	
	count++;
	if(count < Compare){
		PWM_DA = 1;				//ULN2003输出低电平，电机转动
	}
	else{
		PWM_DA = 0;				//ULN2003输出高电平，电机停止
	}
	if(count >= 100)
		count = 0;
	
	//定时器溢出之后需要重新装载
	TH0 = 0xFF;					//50微秒@11.0592MHz
	TL0 = 0xD2; 				//定时器装载周期为50微秒
}